package com.fanjia.taobao.common.util;

public class ResponseUtil{

    /**
     * 成功返回
     *
     * @param object 返回数据
     * @return
     */
    public static ResEntity success(Object object) {
        ResEntity resp = new ResEntity();
        resp.setCode(ResEnum.SUCCESS.getCode());
        resp.setMsg(ResEnum.SUCCESS.getMsg());
        resp.setData(object);
        return resp;
    }

    /**
     * 成功返回  无数据
     *
     * @return
     */
    public static ResEntity success() {
        return success(null);
    }

    /**
     * 失败返回
     *
     * @param responseEnum 响应标识
     * @return
     */
    public static ResEntity error(ResEnum responseEnum) {
        ResEntity resp = new ResEntity();
        resp.setCode(responseEnum.getCode());
        resp.setMsg(responseEnum.getMsg());
        return resp;
    }

    /**
     * 失败返回
     *
     * @param code
     * @param errmsg
     * @return
     */
    public static ResEntity error(int code, String errmsg) {
        ResEntity resp = new ResEntity();
        resp.setCode(code);
        resp.setMsg(errmsg);
        return resp;
    }
}
